import {
	defineConfig
} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
const apiUrl = 'https://consul-api.qiershenghuo.com'
//const apiUrl = 'https://thinkphp8.jiarong.net.cn'
export default defineConfig({
	plugins: [
		uni()
	],
	
	server: {
		proxy: {
			'/base_api': {
                target: apiUrl,
				changeOrigin: true,
				rewrite: path => path.replace(/^\/base_api/, '')
			},

			'/baidu-api': {
				target: 'https://api.map.baidu.com', // 注意这是百度地图API的域名
				changeOrigin: true,
				pathRewrite: {
					'^/baidu-api': ''
				},
				secure: false, // 如果HTTPS证书有问题
				headers: {
					'Referer': 'http://localhost:5173', // 百度API可能需要Referer
					'User-Agent': 'Mozilla/5.0' // 模拟浏览器请求
				}
			}
		}
	},
	base: '/'
})